package com.duowei.diandan.view;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.FrameLayout;

public class CustomFrameLayout extends FrameLayout {
    public CustomFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (mOnKeyEventListener != null) {
            mOnKeyEventListener.onKeyEvent(event);
        }

        return super.dispatchKeyEvent(event);
    }

    public void setOnKeyEventListener(OnKeyEventListener onKeyEventListener) {
        mOnKeyEventListener = onKeyEventListener;
    }

    private OnKeyEventListener mOnKeyEventListener;

    public interface OnKeyEventListener {

        void onKeyEvent(KeyEvent event);
    }
}
